<?php $view->extend('admin/template', 'content', array('title' => 'Admin')); ?>

<div class="col c3">
	<h2>Search</h2>
	<?php echo $searchForm?>
	<p>
		<label>Search by</label>
		<select>
			<option value="username">by Username</option>
			<option value="email">by Email</option>
		</select>
	</p>
	<p>
		<label>Search</label>
		<?php echo $searchForm->input('text','search')?>
	</p>

	<p>
		<?php echo $searchForm->input('submit','submit','Search')?>
	</p>
	<?php echo $searchForm->close() ?>
</div>


<div class="col c3">

	<?php if (isset($searchAcc)): ?>

		<h2><?php echo $searchAcc->getUsername(); ?></h2>
		<?php echo $accForm; ?>
		<?php echo $accForm->input('hidden','uid', $searchAcc->getUsername())?>

		<p>
		<label>Username</label>
		<?php echo $accForm->input('text','username', $searchAcc->getUsername())?>
		</p>

		<p>
		<label>New password</label>
		<?php echo $accForm->input('text','password')?>
		</p>
		
		<p>
		<label>Confirm Password</label>
		<?php echo $accForm->input('text','password2')?>
		</p>
		
		<p>
		<label>Email</label>
		<?php echo $accForm->input('text','email', $searchAcc->getEmail())?>
		</p>
		
		<p>
		<label>Global Account Access</label>
		<select name="gmlevel">
			<?php for($i = 0; $i < 4; $i++):?>
				<option value="<?php echo $i?>" <?php echo $searchAcc->getGmLevel()==$i ? 'selected="selected"' : ''?>><?php $f = $view->getConfig('permission','gmlevels'); echo isset($f[$i]) ? $f[$i] : 'Normal user'; ?></option>
			<?php endfor;?>	
		</select>
		</p>
		
		<p>
			<label>Locked</label>
			<select name="locked">
				<option value="0" <?php echo !$searchAcc->isLocked() ? 'selected="selected"' : ''?>>No</option>
				<option value="1" <?php echo $searchAcc->isLocked() ? 'selected="selected"' : ''?>>Yes</option>	
			</select>
		</p>

		<?php echo $searchForm->input('submit','submit','Save')?>
		<?php echo $accForm->close()?>
	<?php endif;?>
</div>


<div class="col c3">

	<?php if (isset($searchAcc)): ?>
		<?php if ($userBans):?>
			<h2>Active bans</h2>
			<?php foreach($userBans as $ban):?>
			<ul>
				<li><strong>Banned by:</strong> <?php echo $ban->bannedby?></li>
				<li><strong>Ban date:</strong> <?php echo date('y/m/d',$ban->bandate);?></li>
				<li><strong>Unban date:</strong> <?php echo $ban->unbandate ? date('y/m/d',$ban->unbandate) : 'never'?></li>
				<li><strong>Ban reason:</strong> <?php echo $ban->banreason;?></li>	
			</ul>
			<?php endforeach;?>
		<?php else: ?>
			<h2>Ban user</h2>
			<?php echo $banForm;?>
			<p>
				<?php echo $banForm->input('hidden','uid', $searchAcc->getID())?>
				<label>Reason</label>
				<?php echo $banForm->textarea('reason',null, array('cols' => 42))?>
			</p>
			<p>
				<label class="tooltip" title="Leave empty if this is a permanent ban.">Unban date</label>
				<?php echo $accForm->input('text','unbandate', null, array('class' => 'datepicker'))?>
			</p>
			<p>
				<label class="tooltip" title="Unban date will be ignored if perma ban is activated.">Permanent ban?</label>
				<select name="permaban">
					<option value="1">Yes - ignore Unban date</option>
					<option value="0" selected="selected">No</option>
				</select>
			</p>
			<?php echo $searchForm->input('submit','submit','Ban user')?>
			<?php echo $banForm->close() ?>	
	<?php endif; ?>

<?php endif;?>
</div>

<script type="text/javascript">
/* <![CDATA[ */
$(document).ready(function(){ 
	$( ".datepicker" ).datepicker({
		dateFormat: '@'
	});
});
/* ]]> */
</script>